package com.example.androidlearning2400.ui.act

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.example.androidlearning2400.ui.theme.AndroidLearning2400Theme
import com.example.androidlearning2400.ui.comp.BannerSlider
import com.example.androidlearning2400.ui.model.BannerBean

class BannerActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            AndroidLearning2400Theme {
                HomeScreen()
            }
        }
    }
}

@Composable
fun HomeScreen() {
    val bannerList = remember {
        listOf(
            BannerBean(
                imgUrl = "https://picsum.photos/800/400?random=1",
                text = "https://picsum.photos/800/400?random=1"
            ),
            BannerBean(
                imgUrl = "https://picsum.photos/800/400?random=2",
                text = "https://picsum.photos/800/400?random=2"
            ),
            BannerBean(
                imgUrl = "https://picsum.photos/800/400?random=3",
                text = "https://picsum.photos/800/400?random=3"
            )
        )
    }


    Column(modifier = Modifier.fillMaxSize()) {
        BannerSlider(
            bannerList = bannerList,
            autoPlay = true,
            autoPlayDelay = 3000,
            bannerHeight = 220,
            onBannerClick = { println("点击了轮播图：${it.text}") }
        )
    }
}